<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>管理员登录</title>
	{css href="__ROOT__/public/static/css/reset.css" /}
	{css href="__ROOT__/public/static/css/icon.css" /}
	{css href="__ROOT__/public/static/css/common.css" /}
	{css href="__ROOT__/public/static/css/main.css" /}
</head>
<body>
<div id="login">
	<div class="logo" style="background:url(http://image.wmpian.cn/default/logo.png) center no-repeat;"></div>
	<form method="post" class="signin" action="{:url('index')}" onsubmit="return false">
		<div class="row">
			<span class="rd rd-user"></span>
			<input type="text" name="account" placeholder="用户名" data-rule="*" data-errmsg="帐号不能空" />
		</div>
		<div class="row">
			<span class="rd rd-password"></span>
			<input type="password" name="password" placeholder="密码" data-rule="*" data-errmsg="登录密码不能空"  />
		</div>
		<div class="row">
			<span class="rd rd-key"></span>
			<input type="number" name="code" placeholder="验证码" class="code" data-rule="/^\d{4}$/" data-errmsg="验证码错误" />
			<img src="{:captcha_src()}" onclick="this.src='{:captcha_src()}?=' + Math.random()" class="codeimg" />
		</div>
		<input type="submit" value="登录" class="btn" />
	</form>
</div>
{js href="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js" /}
{js href="__ROOT__/public/static/js/functions.js" /}
{js href="__ROOT__/public/static/js/checkform.js" /}
<script type="text/javascript">
var form = new checkForm({
	form : '.signin',
	btn : '.btn',
	error : function (ele,err){
		showMsg(err);
	},
	complete : function (ele){
		var url = $(ele).attr('action'),datas = $(ele).serializeArray();
		showProgress('登录中');
		$.post(url,datas,function (ret){
			showMsg(ret.msg,ret.code);
			if(ret.code == 1 && ret.url) setTimeout(function (){window.location.href = ret.url;},1000);
			var src = $('.codeimg').attr('src');
			var code = src.lastIndexOf('?') > -1 ? src.substr(0,src.lastIndexOf('?')) : src;
			$('.codeimg').attr('src',code + '?' + Math.random());
		},'json');
	}
});
</script>
</body>
</html>